<?php
	$auth = Zend_Auth::getInstance();
	if ($auth->hasIdentity())	
		$u = $auth->getIdentity();
	$sess = new Zend_Session_Namespace(CLU_NS);
	$userPermission = $sess->userPermissions; 
?>

<?if (isset($u)) :?>
<ul class="jsddm" style="float:right">
    <li><a href="javascript:void()">Account</a>
	    <ul>
		     <li><a href="<?=$this->hvnUrl(array('action' => 'view', 'module' => 'user', 'controller' => 'account'),'generic')?>?id=<?=$u->id?>">View <?=$u->name ?></a></li> 
			 <li><a href="<?=$this->hvnUrl(array('action' => 'edit-profile', 'module' => 'user', 'controller' => 'account'),'generic')?>?id=<?=$u->id?>">Edit</a></li>
			 <!-- <li><a href="<?=$this->hvnUrl(array('module' => 'user', 'action' => 'edit'))?>?id=<?=$u->id?>">Upgrade Account</a></li>
             -->
			 <li><a href="<?=$this->hvnUrl(array('action' => 'logout'),'account')?>">Logout </a></li>
		 </ul>
	</li>
	<li><a href="javascript:void()">Search</a>
        <ul>
        	<li><a href="<?=$this->hvnUrl(array('action' => 'search', 'module' => 'place'),'nocontroller')?>">Place</a></li>
            <li><a href="<?=$this->hvnUrl(array('action' => 'search', 'module' => 'event'),'nocontroller')?>">Event</a></li>
            <li><a href="<?=$this->hvnUrl(array('action' => 'search', 'module' => 'tour'),'nocontroller')?>">Tour</a></li>
            <li><a href="<?=$this->hvnUrl(array('action' => 'search', 'module' => 'news'),'nocontroller')?>">News</a></li>
            <li><a href="<?=$this->hvnUrl(array('action' => 'search', 'module' => 'article'),'nocontroller')?>">Article</a></li>
            <?if (strpos($userPermission,'administer everything')) :?>
                <li><a href="<?=$this->hvnUrl(array('action' => 'search', 'module' => 'category'),'nocontroller')?>">Category</a></li>
                <li><a href="/en/user/role/list">List roles</a></li>
                <li><a href="/en/block/index/search">Block</a></li>
                <li><a href="<?=$this->hvnUrl(array('action' => 'search'),'usersearch')?>">Users</a></li>
            <?endif ?>
        </ul>
    </li>
    <li><a href="javascript:void()">Upload</a>
        <ul>
        	<li><a href="<?=$this->hvnUrl(array('action' => 'new', 'module' => 'place'),'nocontroller')?>">Place</a></li>
            <li><a href="<?=$this->hvnUrl(array('action' => 'new', 'module' => 'event'),'nocontroller')?>">Event</a></li>
            <li><a href="<?=$this->hvnUrl(array('action' => 'new', 'module' => 'tour'),'nocontroller')?>">Tour</a></li>
            <li><a href="<?=$this->hvnUrl(array('action' => 'new', 'module' => 'news'),'nocontroller')?>">News</a></li>
            <?if (strpos($userPermission,'administer everything')) :?>	
            <li><a href="<?=$this->hvnUrl(array('action' => 'new', 'module' => 'category'),'nocontroller')?>">Category</a></li>
            <li><a href="/en/user/role/new">Role</a></li>
            <li><a href="/en/block/index/new">Block</a></li>
            <li><a href="<?=$this->hvnUrl(array('action' => 'module-category', 'module' => 'category'),'nocontroller')?>">Mod-Category</a></li>
            <?endif ?>
            
        </ul>
    </li>
</ul>

<?else: ?>

<?=t(435) ?> <?=t(436) ?>, <a href="#loginForm" class="loginDOMWindow" ><?=t(411) ?></a>

 | <a href="<?=$this->hvnUrl(array('action' => 'register'),'account')?>"><?=t(423) ?></a>
  
                <div id="loginForm" style="display: none;color: gray;padding-left:200px">
                        <div><h1 style="color:#0996d4"><?=t(433) ?></h1></div> 
                        <form id="loginFormAjax" accept-charset="UTF-8" action="<?=$this->hvnUrl(array('action' => 'login'),'account')?>" method="POST">
                           <b><?=t(434) ?></b>:<br/><input type="text" value="" id="name" name="name" style="border:1px solid #55b0d6"/>
                           <br/>
                           <b><?=t(432) ?></b>: <br/><input type="password" value="" id="pass" name="pass" style="border:1px solid #55b0d6"/><br/>
                                <div id="id_1" align="center" style="color:red"></div>
                                <br/>
                           <input type="submit" value="Login" name="submit" id="submitForm" 
                           style="background:url('/public/themes/prime/images/login2.png') no-repeat;width:54px;height:19px;border:none;color:white;font-weight:bold;font-family:tahoma;
                           	"/>
                           <br/>
                           <a style="color:#007fb4" href="<?=$this->hvnUrl(array('action' => 'remind-password', 'controller' => "account", "module" => "user"),'generic')?>" > <?=t(464) ?> ? </a>
                        </form>
                </div> 

<script src="/public/library/jquery/jquery.form.js" type="text/javascript"></script>

<script type="text/javascript">

$(function() {
       
        $('.loginDOMWindow').openDOMWindow({ 
                        height:180, 
                        width:250, 
                        positionType:'centered', 
                        positionTop:100, 
                        eventType:'click', 
                        positionLeft:100, 
                        windowSourceID:'#loginForm', 
                        windowPadding:50, 
                        /*draggable:1,*/ 
                        windowBGColor:'#FFFFFF', 
                        borderColor:'#a8d9f8',
                        borderSize: '12', 
                        overlayOpacity:40 
                });
                
                
                $("#loginFormAjax").ajaxForm({
                        dataType: 'json',
                        success: function(json)
                        {
                            if (! json.success)
                            {
                                //$("#loginForm div.loginErrorMessage").html(json.errorMessage);
                                alert(json.errorMessage);
                            }
                            else
                            {
				                var p = /^\/(en|vi|jp|cn|fr|kr)\/logout$/;
				                if (p.test(window.location.pathname))
				                {
				                	//redirect to home
				                	window.location.href = "/";
				                }
				                else
	                                window.location.reload();
                            }        
                                //$('.loginDOMWindow').closeDOMWindow({eventType:'click'}); 
                        }
                });
                
    });
</script>
<?endif ?>
